package com.example.mapper;


import com.ruoyi.common.core.domain.Orders;
import com.ruoyi.common.core.domain.TbCustomerOrderDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作orders相关数据接口
*/
@Mapper
public interface OrdersMapper {

    @Select("select  * from tb_customer_order where order_number = #{orderNumber}")
    Orders selectById(String orderNumber);

    /**
      * 新增
    */
    int insert(Orders orders);

    /**
      * 删除
    */
    int deleteById(Integer id);

    /**
      * 修改
    */
    int updateById(Orders orders);



    /**
      * 查询所有
    */
    List<Orders> selectAll(Orders orders);

    //订单号查order
    @Select("select * from tb_customer_order where order_number = #{orderNo}")
    Orders selectByOrderNo(String orderNo);

//    @Update("UPDATE orders SET status = #{status} WHERE order_no = #{orderNo} and id = #{id}")
    int requestRefund(Orders orders);

    //查询详情
    List<TbCustomerOrderDetail> selectDetailByOrderNo(@Param("orderNumber") String orderNumber);

    //减库存
    int updateInventoryByProductName(@Param("tbCustomerOrderDetails")List<TbCustomerOrderDetail> tbCustomerOrderDetails);


    void updateProductByDetail(@Param("tbCustomerOrderDetails")List<TbCustomerOrderDetail> tbCustomerOrderDetails);
}